const UserModel = require("../../models/WebUserModel")

const UserService ={
    login:async({username,password})=>{
        return UserModel.find({
            username,
            password 
        })
    },
    // upload:async({_id,username,introduction,gender,avatar})=>{
    //     if(avatar){
    //         return UserModel.updateOne({
    //             _id
    //         },{
    //             _id,username,introduction,gender,avatar
    //         })
    //     }else{
    //         return UserModel.updateOne({
    //             _id
    //         },{
    //             _id,username,introduction,gender
    //         })
    //     }
    // },

    // add:async({username,introduction,gender,avatar,role,password})=>{
    //     return UserModel.create({
    //         username,introduction,gender,avatar,role,password
    //     })
    // },

    // getList:async({id})=>{//{}是查询所有记录，【】是要的字段
    //     return id?UserModel.find({_id:id},["username","role","introduction","password"]): 
    //     UserModel.find({},["username","role","avatar","introduction","gender"])
    // },
    // putList:async(body)=>{//{}是查询所有记录，【】是要的字段
    //     return UserModel.updateOne({_id:body._id},body)
    // },
    // delList:async ({_id})=>{
    //     return UserModel.deleteOne({_id})
    // }
}

module.exports = UserService